import 'package:flutter/material.dart';
import './res/listDate.dart';

//ListView列表组件
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter 按钮组件'),
          backgroundColor: Colors.pink[100],
        ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            //ElevatedButton
            ElevatedButton(
              onPressed: () {
                print('点击了ElevatedButton普通按钮');
              },
              child: Text('普通按钮'),
            ),
            TextButton(
              onPressed: () {
                print('点击了TextButton文本按钮');
              },
              child: Text('文本按钮'),
            ),
            OutlinedButton(onPressed: null, child: Text('外边框按钮')),
            IconButton(onPressed: () {}, icon: Icon(Icons.ac_unit_rounded)),
          ],
        ),
        SizedBox(height: 20),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            ElevatedButton.icon(
              onPressed: () {},
              label: Text('发送'),
              icon: Icon(Icons.send),
            ),
            TextButton.icon(
              onPressed: () {},
              icon: Icon(Icons.add),
              label: Text('添加'),
            ),
            OutlinedButton.icon(
              onPressed: () {},
              icon: Icon(Icons.delete),
              label: Text('删除'),
            ),
          ],
        ),
        SizedBox(height: 10),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            ElevatedButton(
              style: ButtonStyle(
                backgroundColor: WidgetStateProperty.all(Colors.blue), //背景颜色
                foregroundColor: WidgetStateProperty.all(
                  const Color.fromARGB(255, 216, 14, 14),
                ), //文字图标的颜色
              ),
              onPressed: () {},
              child: Text('保存'),
            ),
          ],
        ),

        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Container(
              width: 180,
              height: 30,
              child: ElevatedButton(onPressed: () {}, child: Text('取消')),
            ),
            Container(
              width: 200,
              height: 60,
              child: ElevatedButton.icon(
                onPressed: () {},
                label: Text('大按钮'),
                icon: Icon(Icons.arrow_forward),
              ),
            ),
          ],
        ),
        SizedBox(height: 10),
        Row(
          children: [
            Expanded(
              flex: 1,
              child: Container(
                margin: EdgeInsets.all(20),
                child: ElevatedButton(
                  onPressed: null,
                  child: Text('全选'),
                  style: ButtonStyle(
                    backgroundColor: WidgetStateProperty.all(
                      Colors.blue,
                    ), //背景颜色
                    foregroundColor: WidgetStateProperty.all(
                      Colors.white,
                    ), //文字图标的颜色
                  ),
                ),
              ),
            ),
          ],
        ),
        SizedBox(height: 10),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            ElevatedButton(
              onPressed: () {},
              child: Text('非圆角'),
              style: ButtonStyle(
                shape: WidgetStateProperty.all(
                  RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(5),
                  ),
                ),
              ),
            ),
          ],
        ),
        SizedBox(height: 10),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            SizedBox(
              width: 150,
              height: 150,
              child: ElevatedButton(
                onPressed: () {},
                child: Text('圆形'),
                style: ButtonStyle(
                  shape: WidgetStateProperty.all(
                    CircleBorder(side: BorderSide(width: 2, color: Colors.red)),
                  ),
                ),
              ),
            ),
          ],
        ),
        SizedBox(height: 10),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            OutlinedButton(
              onPressed: () {}, 
              child: Text('带边框的按钮'),
              style: ButtonStyle(
                side: WidgetStateProperty.all(
                  BorderSide(width: 2, color: Colors.red),
                ),
              ),
              ),
          ],
        ),
      ],
    );
  }
}
